package myPoker;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Method {
    List<List<Integer>> card=new ArrayList<>();
    public static String suit[]={"♥","♠","♣","♦"};
    public List<Poker> getPoker() {
        List<Poker> gPoker=new ArrayList<>();
        for (int i = 1; i <=13 ; i++) {
            for (int j = 0; j < 4; j++) {
                String s=suit[j];
                Poker poker=new Poker(i,s);
                gPoker.add(poker);
            }
        }
        return gPoker;
    }

    //打乱牌序
    public void Disrupt(List<Poker> pokers){
        Random random=new Random();
        for(int i =pokers.size()-1;i>0;i--){
            int index=random.nextInt(i);
            swap(pokers,i,index);
        }
    }
    public void swap(List<Poker> pokers,int i,int j){
        Poker tmp=pokers.get(i);
        pokers.set(i,pokers.get(j));
        pokers.set(j,tmp);
    }

    public List<List<Poker>> play (List<Poker> pokers){
        List<Poker> hand0=new ArrayList<>();
        List<Poker> hand1=new ArrayList<>();
        List<Poker> hand2=new ArrayList<>();

        List<List<Poker>> hand = new ArrayList<>();
        hand.add(hand0);
        hand.add(hand1);
        hand.add(hand2);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Poker poker =pokers.remove(0);
                hand.get(j).add(poker);
            }
        }
        return hand;
    }
}
